1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19 
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 
25 module adw.ButtonContent;
26 
27 private import adw.c.functions;
28 public  import adw.c.types;
29 private import glib.ConstructionException;
30 private import glib.Str;
31 private import glib.c.functions;
32 private import gobject.ObjectG;
33 private import gtk.AccessibleIF;
34 private import gtk.AccessibleT;
35 private import gtk.BuildableIF;
36 private import gtk.BuildableT;
37 private import gtk.ConstraintTargetIF;
38 private import gtk.ConstraintTargetT;
39 private import gtk.Widget;
40 
41 
42 /**
43  * A helper widget for creating buttons.
44  * 
45  * <picture>
46  * <source srcset="button-content-dark.png" media="(prefers-color-scheme: dark)">
47  * <img src="button-content.png" alt="button-content">
48  * </picture>
49  * 
50  * `AdwButtonContent` is a box-like widget with an icon and a label.
51  * 
52  * It's intended to be used as a direct child of [class@Gtk.Button],
53  * [class@Gtk.MenuButton] or [class@SplitButton], when they need to have both an
54  * icon and a label, as follows:
55  * 
56  * ```xml
57  * <object class="GtkButton">
58  * <property name="child">
59  * <object class="AdwButtonContent">
60  * <property name="icon-name">document-open-symbolic</property>
61  * <property name="label" translatable="yes">_Open</property>
62  * <property name="use-underline">True</property>
63  * </object>
64  * </property>
65  * </object>
66  * ```
67  * 
68  * `AdwButtonContent` handles style classes and connecting the mnemonic to the
69  * button automatically.
70  * 
71  * ## CSS nodes
72  * 
73  * ```
74  * buttoncontent
75  * ├── image
76  * ╰── label
77  * ```
78  * 
79  * `AdwButtonContent`'s CSS node is called `buttoncontent`. It contains the
80  * subnodes `image` and `label`.
81  * 
82  * When inside a `GtkButton` or `AdwSplitButton`, the button will receive the
83  * `.image-text-button` style class. When inside a `GtkMenuButton`, the
84  * internal `GtkButton` will receive it instead.
85  * 
86  * ## Accessibility
87  * 
88  * `AdwButtonContent` uses the `GTK_ACCESSIBLE_ROLE_GROUP` role.
89  *
90  * Since: 1.0
91  */
92 public class ButtonContent : Widget
93 {
94 	/** the main Gtk struct */
95 	protected AdwButtonContent* adwButtonContent;
96 
97 	/** Get the main Gtk struct */
98 	public AdwButtonContent* getButtonContentStruct(bool transferOwnership = false)
99 	{
100 		if (transferOwnership)
101 			ownedRef = false;
102 		return adwButtonContent;
103 	}
104 
105 	/** the main Gtk struct as a void* */
106 	protected override void* getStruct()
107 	{
108 		return cast(void*)adwButtonContent;
109 	}
110 
111 	/**
112 	 * Sets our main struct and passes it to the parent class.
113 	 */
114 	public this (AdwButtonContent* adwButtonContent, bool ownedRef = false)
115 	{
116 		this.adwButtonContent = adwButtonContent;
117 		super(cast(GtkWidget*)adwButtonContent, ownedRef);
118 	}
119 
120 
121 	/** */
122 	public static GType getType()
123 	{
124 		return adw_button_content_get_type();
125 	}
126 
127 	/**
128 	 * Creates a new `AdwButtonContent`.
129 	 *
130 	 * Returns: the new created `AdwButtonContent`
131 	 *
132 	 * Since: 1.0
133 	 *
134 	 * Throws: ConstructionException GTK+ fails to create the object.
135 	 */
136 	public this()
137 	{
138 		auto __p = adw_button_content_new();
139 
140 		if(__p is null)
141 		{
142 			throw new ConstructionException("null returned by new");
143 		}
144 
145 		this(cast(AdwButtonContent*) __p);
146 	}
147 
148 	/**
149 	 * Gets the name of the displayed icon.
150 	 *
151 	 * Returns: the icon name
152 	 *
153 	 * Since: 1.0
154 	 */
155 	public string getIconName()
156 	{
157 		return Str.toString(adw_button_content_get_icon_name(adwButtonContent));
158 	}
159 
160 	/**
161 	 * Gets the displayed label.
162 	 *
163 	 * Returns: the label
164 	 *
165 	 * Since: 1.0
166 	 */
167 	public string getLabel()
168 	{
169 		return Str.toString(adw_button_content_get_label(adwButtonContent));
170 	}
171 
172 	/**
173 	 * Gets whether an underline in the text indicates a mnemonic.
174 	 *
175 	 * Returns: whether an underline in the text indicates a mnemonic
176 	 *
177 	 * Since: 1.0
178 	 */
179 	public bool getUseUnderline()
180 	{
181 		return adw_button_content_get_use_underline(adwButtonContent) != 0;
182 	}
183 
184 	/**
185 	 * Sets the name of the displayed icon.
186 	 *
187 	 * Params:
188 	 *     iconName = the new icon name
189 	 *
190 	 * Since: 1.0
191 	 */
192 	public void setIconName(string iconName)
193 	{
194 		adw_button_content_set_icon_name(adwButtonContent, Str.toStringz(iconName));
195 	}
196 
197 	/**
198 	 * Sets the displayed label.
199 	 *
200 	 * Params:
201 	 *     label = the new label
202 	 *
203 	 * Since: 1.0
204 	 */
205 	public void setLabel(string label)
206 	{
207 		adw_button_content_set_label(adwButtonContent, Str.toStringz(label));
208 	}
209 
210 	/**
211 	 * Sets whether an underline in the text indicates a mnemonic.
212 	 *
213 	 * Params:
214 	 *     useUnderline = whether an underline in the text indicates a mnemonic
215 	 *
216 	 * Since: 1.0
217 	 */
218 	public void setUseUnderline(bool useUnderline)
219 	{
220 		adw_button_content_set_use_underline(adwButtonContent, useUnderline);
221 	}
222 }